<?php echo $this->breadcrumbs()->addPage('Envolvidos')->render() ?>

<?php
echo $this->pagenav()->openList();

$html = '<div class="total_documents">Total de itens: <strong>' . $this->totalDocumentos . '</strong></div>';
echo $this->pagenav()->customHelperLinks($html);

echo $this->pagenav()->closeList();
?>

<div id="article">
    <form action="" method="post">
        <fieldset class="search">
            <legend>Pesquisa</legend>
            <?php
            echo $this->fieldList()->open();
            ?>
            <dt>
            <div style="width:175px;">
                <input type="radio" name="tipo" id="nome" value="nome" /> Nome
                <input type="radio" name="tipo" id="cpf" value="cpf" /> CPF
                <input type="radio" name="tipo" id="cnpj" value="cnpj" /> CNPJ
            </div>
            </dt>
            <?php
            echo $this->fieldList()->textbox('Nome/CPF', 'q', $this->q);
            echo $this->buttonlist()->open();
            echo $this->buttonlist()->button('Buscar');
            echo $this->buttonlist()->close(true);
            ?>
        </fieldset>
    </form>

    <?php if ($this->paginator): ?>
        <table class="grid">
            <thead>
                <tr>
                    <th>CPF</th>
                    <th>Nome</th>
                    <th>Bairro</th>
                    <th>Processo</th>
                </tr>
            </thead>
            <tfoot>
                <tr>
                    <td colspan="2"><?php echo $this->partial('pagination.phtml', array('paginator' => $this->paginator)) ?></td>
                </tr>
            </tfoot>
            <tbody>
                <?php $i = 0 ?>
                <?php if (count($this->paginator) > 0): ?>
                    <?php foreach ($this->paginator as $p): ?>
                        <tr class="<?php echo (++$i % 2) ? 'even' : 'odd' ?>">
                            <td><?php echo $p->manifestante->cpf ? $p->manifestante->cpf : "anônimo";  ?></td>
                            <td><?php echo $p->manifestante->nome ?></td>
                            <td><?php echo $p->manifestante->bairro->nome ? $p->manifestante->bairro->nome : ' - ' ?></td>
                            <td><?php echo str_replace("_", "/", $p->nome) ?></td>
                        </tr>
                    <?php endforeach; ?>
                <?php else: ?>
                    <tr>
                        <td colspan="3">Nenhum envolvido encontrado.</td>
                    </tr>
                <?php endif ?>
            </tbody>
        </table>
    <?php endif ?>
</div>